﻿//-------------------------------------------------------------------------------------------
// <copyright file="TransactionViewModel.cs" company="Russell Wilkins">
//     Copyright (c) Russell Wilkins 2014. All Rights Reserved.
// </copyright>
// <author>Russell Wilkins</author>
// <license href="license.txt">
//     The use of this software is governed by the Microsoft Public License
//     which is included with this distribution.
// </license>
//-------------------------------------------------------------------------------------------
namespace Ripple.TestClient.ViewModels
{
    using Ripple.Data;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;

    /// <summary>
    /// TODO: Describe the class
    /// </summary>
    public class TransactionViewModel : ViewModel<Transaction>
    {
        public static readonly DependencyProperty DateProperty = DependencyProperty.Register("Date", typeof(DateTime), typeof(TransactionViewModel));
        public static readonly DependencyProperty IdProperty = DependencyProperty.Register("Id", typeof(string), typeof(TransactionViewModel), new PropertyMetadata(string.Empty));

        public static readonly DependencyProperty TransactionTypeProperty = DependencyProperty.Register("TransactionType", typeof(string), typeof(TransactionViewModel), new PropertyMetadata(string.Empty));

        /// <summary>
        /// Initializes a new instance of the TransactionViewModel class.
        /// </summary>
        public TransactionViewModel(Transaction model)
        {
            this.Model = model;
        }

        public DateTime Date
        {
            get { return (DateTime)GetValue(DateProperty); }
            set { SetValue(DateProperty, value); }
        }

        public string Id
        {
            get { return (string)GetValue(IdProperty); }
            set { SetValue(IdProperty, value); }
        }

        public string TransactionType
        {
            get { return (string)GetValue(TransactionTypeProperty); }
            set { SetValue(TransactionTypeProperty, value); }
        }

        protected override void RefreshData()
        {
            this.Id = this.Model.Id;
            this.Date = this.Model.Date;
            this.TransactionType = this.Model.TransactionType.ToString();
        }
    }
}